package com.evil.application.pojo.dto.process.node.save;

import com.evil.application.pojo.entity.ApplicationProcess;
import lombok.Data;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class CopyNodeDTO {

    /**
     * 流程
     */
    private ApplicationProcess process;

    /**
     * 新旧节点id映射
     */
    private Map<Long, Long> nodeIdMap;

    /**
     * 新旧控件id映射
     */
    private Map<Long, Long> controlIdMap;

    /**
     * 校验错误收集
     */
    private List<String> errorMsgList;

    public CopyNodeDTO() {
        this.nodeIdMap = new LinkedHashMap<>();
        this.errorMsgList = new ArrayList<>();
    }

    public CopyNodeDTO(ApplicationProcess process, Map<Long, Long> controlIdMap) {
        this.process = process;
        this.controlIdMap = controlIdMap;
        this.nodeIdMap = new LinkedHashMap<>();
        this.errorMsgList = new ArrayList<>();
    }

    /**
     * 是否有校验错误
     *
     * @return boolean
     */
    public boolean hasError() {
        return !errorMsgList.isEmpty();
    }
}
